package routers

import (
	"CMETO/controllers/goodsController"
	middleware "CMETO/middlewares"

	"github.com/gin-gonic/gin"
)

func GoodsApi(r *gin.RouterGroup) {
	var goodsType goodsController.GoodsTypeController
	goodsTypeRouter := r.Group("/goodsType", middleware.JWTAuthPlus())
	{
		goodsTypeRouter.GET("/", goodsType.QueryGoodsTypes)
		goodsTypeRouter.GET("/upper", goodsType.QueryTypeUpper)
		goodsTypeRouter.GET("/upper/:id", goodsType.QueryAllUpper)
		goodsTypeRouter.POST("/", goodsType.AddGoodsType)
		goodsTypeRouter.PUT("/", goodsType.UpdateGoodsType)
		goodsTypeRouter.DELETE("/", goodsType.DeleteGoodsType)
	}
	var goods goodsController.GoodsController
	goodsRouter := r.Group("/goods", middleware.JWTAuthPlus())
	{
		goodsRouter.GET("/", goods.QueryGoods)
		goodsRouter.POST("/", goods.AddGoods)
		goodsRouter.PUT("/", goods.UpdateGoods)
		goodsRouter.PUT("/upOrDown", goods.UpdateGoodsStatus)
		goodsRouter.DELETE("/", goods.DeleteGoods)
	}
}
